package main

import "fmt"

/*
	结构体嵌套
*/

type User struct {
	UserName string
	Password string
	Address  Address //表示User结构体嵌套Address结构体
}

type Address struct {
	Name  string
	Phone string
	City  string
}

func main() {
	u1 := User{
		UserName: "李四",
		Password: "123456",
		Address: Address{
			Name:  "李先生",
			Phone: "15632678987",
			City:  "深圳市龙岗区",
		},
	}

	fmt.Printf("%#v\n", u1) //main.User{UserName:"李四", Password:"123456", Address:main.Address{Name:"李先生", Phone:"15632678987", City:"深圳市龙岗区"}}

	var u2 User
	u2.UserName = "张三"
	u2.Password = "456789"
	u2.Address.Name = "张先生"
	u2.Address.Phone = "15323132132"
	u2.Address.City = "深圳市福田区"

	fmt.Printf("%#v\n", u2) //main.User{UserName:"张三", Password:"456789", Address:main.Address{Name:"张先生", Phone:"15323132132", City:"深圳市福田区"}}

}
